package cn.edu.scau.cmi.linpeiwei.controller;

import cn.edu.scau.cmi.linpeiwei.singleton.Chairman;
import javafx.fxml.FXML;

import javafx.scene.control.Button;

import javafx.scene.control.TextField;
import javafx.scene.layout.AnchorPane;
import javafx.scene.text.Text;

public class SingletonController extends AnchorPane{
	@FXML
	private Button mybtn;
	@FXML
	private TextField mytextfield;
	@FXML
	private Text mytext;

	private Chairman chairman = Chairman.getChairman("毛泽东");
	String name;

	public void eventButton() {
		if (!mytextfield.getText().isEmpty()) {
			name = mytextfield.getText();
			Chairman chairman1 = Chairman.getChairman(name);
			if(chairman.getName().equals(name))
				mytext.setText("毛泽东已存在");
			else 
				if (chairman1 == chairman)
					mytext.setText("创建失败，只能存在一个毛泽东");
				else
					mytext.setText("创建成功");
			
		}
		else
			mytext.setText("请输入名字");
		mytext.setVisible(true);
			
	}

}
